@extends('admin.app')

@section('breadcrumb')
  <div class="bg-light lter b-b wrapper-md">
    <ol class="breadcrumb bg-light lter m-n no-padder">
      <li><a href="{{ admin_action('HomeController@index') }}">主页</a></li>
      <li>Rbac</li>
      <li class="active">角色管理</li>
    </ol>
  </div>
@endsection

@section('content')
  <div class="panel panel-default">
    <div class="panel-heading font-bold">
      角色信息列表
    </div>
    <div class="panel-body">
      <form action="{{ admin_action('Rbac\RolesController@index') }}" class="form-horizontal">
        <div class="form-group">
          <label for="input1" class="col-sm-1 control-label">名称</label>
          <div class="col-sm-2">
            <input type="text" class="form-control" name="search" value="{{ $query['search'] ?? '' }}" placeholder="请输入查询条件">
          </div>
          <div class="col-sm-9 text-right">
            <button type="submit" class="btn btn-primary">查询</button>
            <a class="btn btn-default btn-addon" href="{{ admin_action('Rbac\RolesController@create') }}">
              <i class="fa fa-plus"></i>新增角色
            </a>
          </div>
        </div>
      </form>
      <div class="table-responsive">
        <table class="table table-striped b-t b-light">
          <thead>
          <tr>
            <th>#</th>
            <th>权限名</th>
            <th>权限码</th>
            <th class="hidden-xs">描述</th>
            <th></th>
          </tr>
          </thead>
          <tbody>
          @forelse ($roles as $role)
            <tr>
              <td>{{ $role->id }}</td>
              <td>{{ $role->name }}</td>
              <td>{{ $role->slug }}</td>
              <td class="hidden-xs">{{ $role->description }}</td>
              <td>
                <a class="btn btn-xs btn-info" href="{{ admin_action('Rbac\RolesController@permission', [$role]) }}" data-toggle="tooltip" title="分配角色权限">
                  <i class="fa fa-gear"></i>
                </a>
                <a class="btn btn-xs btn-primary" href="{{ admin_action('Rbac\RolesController@edit', [$role]) }}" data-toggle="tooltip" title="编辑角色信息">
                  <i class="fa fa-pencil"></i>
                </a>
                <form class="inline" action="{{ admin_action('Rbac\RolesController@destroy', [$role]) }}" method="post">
                  {{ csrf_field() }}
                  {{ method_field('DELETE') }}
                  <button type="button" data-swal-role="delete-confirm" class="btn btn-xs btn-danger" data-toggle="tooltip" title="删除角色信息">
                    <i class="fa fa-trash-o"></i>
                  </button>
                </form>
              </td>
            </tr>
          @empty
            <tr>
              <td colspan="5" class="text-center">没有找到角色记录</td>
            </tr>
          @endforelse
          </tbody>
        </table>
      </div>
    </div>
    <div class="panel-footer">
      <div class="row">
        <div class="col-sm-12 text-right text-center-xs">
          {{ $links }}
        </div>
      </div>
    </div>
  </div>
@endsection